#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>


int main()
{
   pid_t id = fork();
   if(id == 0)
   {
      int cnt = 5;
      while(cnt--)
      {
        printf(" i am child procrss,pid:%d,ppid:%d\n",getpid(),getppid());
        sleep(1);
      }
      printf("子进程退出\n");
      exit(1);
   }
   printf("父进程开始休眠,等待子进程\n");
   sleep(10);
   printf("父进程开始回收\n");

   int status = 0; 
   pid_t rid = waitpid(id,&status,0);
   if(rid > 0)
   {
    printf("wait success,rid:%d,status:%d\n",rid,status);
   }

    printf("父进程回收结束\n");
    sleep(3);

  return 0;
}




